<?php
namespace app\api\controller;

use think\Db;
class Index
{
    /**
     * @api {get} api\index\nav 获取导航
     * @apiGroup Group
     * @apiDescription 获取导航
     * @apiSuccess {String} id 导航id
     * @apiSuccess {String} name 导航名称
     * @apiSuccess {String} url 导航url
     * @apiSuccessExample 数据:
     * {
    "code": 200,
    "mag": "请求成功",
    "data": [
    {
    "id": 1,
    "name": "首页",
    "url": "index/index"
    }
    ]
    },
     */
    public function nav(){
        $data=Db::name('nav')
            ->field('id,name,url')
            ->select();
        if($data){
            return json(['code'=>200,'mag'=>"请求成功",'data'=>$data,'a'=>$data]);
        }else{
            return json(['code'=>0,'mag'=>"请求失败"]);
        }
    }
    /**
     * @api {get} api\index\job 获取招聘信息
     * @apiGroup Group
     * @apiDescription 获取招聘信息
     * @apiSuccess {int} id 招聘信息id
     * @apiSuccess {String} name 招聘职位
     * @apiSuccess {text} content 职位介绍
     * @apiSuccess {int} create_time 创建时间
     * @apiSuccessExample 数据:
     * {
    "code": 200,
    "msg": "请求成功",
    "data": [
    {
    "id": 1,
    "name": "市场销售员",
    "content": "很多很多很好的好滴好滴好滴会好的会好的",
    "create_time": "2020-12-22"
    }
    ]
    }
     */
    public function job(){
        $data=Db::name('job')
            ->field('id,name,content,create_time')
            ->select();
        foreach ($data as $k=>$v){
            $data[$k]['content']= strip_tags(str_replace('&nbsp;','',$v['content']));
            $data[$k]['create_time']=date('Y-m-d',$v['create_time']);
        }
        if($data){
            return json(['code'=>200,'msg'=>"请求成功",'data'=>$data]);
        }else{
            return json(['code'=>0,'msg'=>"请求失败"]);
        }
    }



}